package com.zhongkun.datahome.service.res.project;

import com.zhongkun.datahome.service.domain.Project;
import lombok.Data;

import java.util.Map;

/**
 * @Author: lifengsheng
 * @Date: 2025/4/17 17:16
 * @Desc
 */
@Data
public class ProjectVo extends Project {
    private String operatorName;

    public static ProjectVo convert(Project project, Map<Long, String> nameMap) {
        ProjectVo projectVo = new ProjectVo();
        projectVo.setId(project.getId());
        projectVo.setProjectName(project.getProjectName());
        projectVo.setStatus(project.getStatus());
        String operatorName = project.getUpdateBy().compareTo(0L) == 0
                ? nameMap.get(project.getCreateBy()) : nameMap.get(project.getUpdateBy());
        projectVo.setOperatorName(operatorName);
        projectVo.setCreateTime(project.getCreateTime());
        projectVo.setUpdateTime(project.getUpdateTime());
        projectVo.setCreateBy(project.getCreateBy());
        projectVo.setUpdateBy(project.getUpdateBy());
        return projectVo;
    }
}
